<?php
require_once 'config.php';


if (U1_Account_Validate::issetCode())
{
	U1_Player::getInstanceDb();
	if (null !== ($user = U1_Account_Validate::createIfCodeValid()))
		U1_Account_Connexion::connect($user);
	else
		echo 'Le compte demandé n\'existe pas ou est déjà activer.';
}
else
{
	$validate = new U1_Account_Validate();

	if ($validate->isSubmit())
	{
		if ($validate->isValid())
		{
			U1_Player::getInstanceDb();
			if (null !== ($user = $validate->create()))
				U1_Account_Connexion::connect($user);
			else
				echo 'Le compte demandé n\'existe pas ou est déjà activer.';
		}
		else
			var_dump($validate->getMessages());
	}

	echo $validate->render(DIR_VIEW.'Account/Validate.php');
	var_dump($validate->getMessages());
}